package Logic;

import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;

import javax.swing.JOptionPane;
import Message.*;
import OCSF.*;
/**
 * this class runing the main tra

 */
public class TaskAssignment {

 ConnectionToClient client;
 
	public TaskAssignment(Object msg, ConnectionToClient client) throws SQLException, IOException{
		
		
	
		  String[] str;
		  
		//  System.out.println(msg);

		  msg= msg.toString().substring(1, msg.toString().length()-1); // remove the [] from the msg by substring 
		  str = msg.toString().split("[ , ] "); // remove the , from msg and spliting it to tiny str array parts  
		
	//	  System.out.println(str[0]);
	//	  System.out.println(str[1]);             // test prints 
	//	  System.out.println(str[2]);
		  
		 
		  
	      switch(str[0])
	      {          
			      case ("login"):
				  {
					
			    	  MessageLogin login =  new MessageLogin(str, client);  
			    	  login.execute();
					  
			      break;
				  }
			      case("logout"):
			      {
			    	MessageLogout logout=new MessageLogout(str,client);
			    	logout.execute();
			    	  break;
			      }
				  
			      case("OneTimeRequest"):
			      {
				    	MessageOneTimeRequest motr=new MessageOneTimeRequest(str,client);
				    	motr.execute();
				    	  break;
				      }
			      
	   
	      default:
			  JOptionPane.showMessageDialog(null, "This Option isn't handeled yet!!!!",null, JOptionPane.WARNING_MESSAGE);
	    	  break;
	      }
	
  
    	  
	  }
	
}

